package com.chansos.dubbogo.common;

public enum Registry {
    Zookeeper("Zookeeper", "zookeeper", "127.0.0.1:2181", true),
    Nacos("Nacos", "nacos", "127.0.0.1:8848", false);

    private final String name;
    private final String alias;
    private final String defaultAddress;
    private final boolean selected;

    public String getName() {
        return name;
    }

    public String getAlias() {
        return alias;
    }

    public String getDefaultAddress() {
        return defaultAddress;
    }

    public boolean isSelected() {
        return selected;
    }

    Registry(String name, String alias, String defaultAddress, boolean selected) {
        this.name = name;
        this.alias = alias;
        this.defaultAddress = defaultAddress;
        this.selected = selected;
    }

    public static Registry parse(String name) {
        if (null == name) {
            return Zookeeper;
        }
        for (Registry value : values()) {
            if (value.name().equals(name)) {
                return value;
            }
        }
        return Zookeeper;
    }
}
